package com.wanye.entity;

import com.wanye.validator.Phone;
import org.hibernate.validator.constraints.NotBlank;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.io.Serializable;

/**
 * Created by wanye on 2017/6/3.
 */
public class User implements Serializable{
    @NotNull(message = "id不能为空",groups = UPDATE.class)
    @Null(message = "id必须为空",groups = SAVE.class)
    private Integer id;
    @NotBlank(message = "姓名不能为空",groups = {SAVE.class,UPDATE.class})
    private String name;
    @Min(value = 18,message = "年龄不能小于18岁",groups = {SAVE.class,UPDATE.class})
    private Integer age;
    private Integer create;

    @Phone(groups = {SAVE.class,UPDATE.class})
    private String phone;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Integer getCreate() {
        return create;
    }

    public void setCreate(Integer create) {
        this.create = create;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", create=" + create +
                ", phone='" + phone + '\'' +
                '}';
    }

    public interface SAVE{}
    public interface UPDATE{}

}
